<?php
namespace app\api\controller;

use app\wechat\service\WechatService;
use kbitAdmin\tools\Data;

/**
 * Class Index
 * @package app\index\controller
 */
class Qrcode extends Base
{

    public function __construct(\think\App $app)
    {
        parent::__construct($app);
    }


    /*
     * 获取绑定二维码
     * @return mixed
     */
    public function getBindQrcode(){
        $this->checkUserLogin();
        $data = [
            'uid' => $this->user['id'],
        ];
        // 生成二维码
        $qrcode_url = WechatService::createInnerFunctionQrcode('app\\common\\service\\UserService', 'bindUser', $data, 600);
        return $this->returnSuccess(['url' => $qrcode_url]);
    }

    public function getLoginQrcode(){
        $login_key = Data::uniqidNumberCode(10);
        $data = [
            'login_key' => $login_key,
        ];
        $qrcode_url = WechatService::createInnerFunctionQrcode('app\\common\\service\\UserService', 'wechatLogin', $data, 600);
        return $this->returnSuccess(['url' => $qrcode_url, 'login_key' => $login_key]);
    }
}